<?php
class cast_role extends Model{
	public static function getTableName(){
		return 'cast_role';
	}

	public function findByInSql($instr, $type)
	{
		$instr = is_null($instr) ? '' : $instr;
		$sql = "select * from ".self::getTableName()." where id in(".$instr.") and cast_role_type_id='{$type}' order by id";
		return Model::$dbo['r']->findBySql(__class__, $sql);
	}

	/**
	 * get cast's role type
	 *
	 * @param int $cast_role_id : cast's role id
	 *
	 * @used by : CastUpdateAction.class.php
	 */
	public static function getCastRoleType($cast_role_id)
	{
		$sql = "select b.system_label from ".self::getTableName()." a left join cast_role_type b on a.cast_role_type_id=b.id where a.id='{$cast_role_id}'";
		$ret = Model::$dbo['r']->findBySql(__class__, $sql);
		return isset($ret[0]) ? $ret[0]->system_label : false;
	}
}
?>
